/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package DAO;

import java.util.List;
import model.TransportEnterprise;
import org.hibernate.Query;
import org.hibernate.Session;
import util.NewHibernateUtil;

/**
 *
 * @author LA
 */
public class TransportEnterpriseDAOImpl implements TransportEnterpriseDAO{
    Session session = NewHibernateUtil.getSession();

    @Override
    public void create(TransportEnterprise te) {
        session.beginTransaction();
        session.save(te);
        session.getTransaction().commit();
    }

    @Override
    public void edit(TransportEnterprise te) {
        session.beginTransaction();
        session.saveOrUpdate(te);
        session.getTransaction().commit();
    }

    @Override
    public void remove(TransportEnterprise te) {
        session.beginTransaction();
        session.delete(te);
        session.getTransaction().commit();
    }

    @Override
    public List<TransportEnterprise> findAll() {
        Query q = session.createQuery("FROM TransportEnterprise");
        return (List<TransportEnterprise>) q.list();
    }
    
}
